package de.tabuma.wsdl2xform.view;


import de.tabuma.lib.tabumaview;
import java.io.*;
import java.util.*;
import java.util.logging.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.google.appengine.api.users.*;
import de.tabuma.wsdl2xform.*;

/**
 *
 * @author $Author: alefen $
 * @version $Revision: 1.3.4.1 $
 * @since $Date: 2010/01/13 10:23:55 $
 */
public class head extends tabumaview {
   
    private static Logger log = Logger.getLogger(head.class.getName());

    public head(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }
    
    public void processRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response,PrintWriter out)
     {
        try {

            UserService userService = UserServiceFactory.getUserService();
            User user = userService.getCurrentUser();

            RequestDispatcher disp1 = context.getRequestDispatcher("/intern/head1.html");
            disp1.include(request, response);

            out.println("</head>");
            out.println("<body>");

            disp1 = context.getRequestDispatcher("/intern/head2.html");
            disp1.include(request, response);

            out.println(java.util.ResourceBundle.getBundle(de.tabuma.wsdl2xform.constants.projectLanguageBundle).getString("template.text.protectedarea")+" "+user.getEmail()+", version:"+de.tabuma.wsdl2xform.constants.version);

            disp1 = context.getRequestDispatcher("/intern/head3.html");
            disp1.include(request, response);

            String nameStart = java.util.ResourceBundle.getBundle(de.tabuma.wsdl2xform.constants.projectLanguageBundle).getString("navigation.link.start");
            String nameProjects = java.util.ResourceBundle.getBundle(de.tabuma.wsdl2xform.constants.projectLanguageBundle).getString("navigation.link.projects");
            String nameOrder = java.util.ResourceBundle.getBundle(de.tabuma.wsdl2xform.constants.projectLanguageBundle).getString("navigation.link.orders");
            String nameCostumerList = java.util.ResourceBundle.getBundle(de.tabuma.wsdl2xform.constants.projectLanguageBundle).getString("navigation.link.costumerList");
            String nameAdminarea = java.util.ResourceBundle.getBundle(de.tabuma.wsdl2xform.constants.projectLanguageBundle).getString("navigation.link.adminarea");

            String nav_start = "" + de.tabuma.wsdl2xform.controller.constants.NAVID_START;
            String nav_projects =  "" + de.tabuma.wsdl2xform.controller.constants.NAVID_PROJECTS;
            String nav_orders =  "" + de.tabuma.wsdl2xform.controller.constants.NAVID_ORDERS;
            String nav_costumerlist =  "" + de.tabuma.wsdl2xform.controller.constants.NAVID_COSTUMERLIST;
            String nav_adminarea = "" +de.tabuma.wsdl2xform.controller.constants.NAVID_ADMINAREA;

            String servlet_name = de.tabuma.wsdl2xform.controller.constants.SERVLET_NAME;
            String mainnav = de.tabuma.wsdl2xform.controller.constants.MAINNAV;

            out.println("<a href=\""+servlet_name+"?"+mainnav+"="+nav_start+"\" class=\"navigationLink\">"+nameStart+"</a>");
            out.println("| <a href=\""+servlet_name+"?"+mainnav+"="+nav_costumerlist+"\" class=\"navigationLink\">"+nameCostumerList+"</a>");
            out.println("| <a href=\""+servlet_name+"?"+mainnav+"="+nav_projects+"\" class=\"navigationLink\">"+nameProjects+"</a>");
            out.println("| <a href=\""+servlet_name+"?"+mainnav+"="+nav_orders+"\" class=\"navigationLink\">"+nameOrder+"</a>");
            
            if(userService.isUserAdmin()) {
                out.println("| <a href=\""+servlet_name+"?"+mainnav+"="+nav_adminarea+"\" class=\"navigationLink\">"+nameAdminarea+"</a>");
            }
            
            disp1 = context.getRequestDispatcher("/intern/head4.html");
            disp1.include(request, response);
        } 
        catch(Exception e) {
            log.warning(e.getMessage());
        }
    }

}
